package com.theater.asp;

import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class SeatController
{
    private static final Logger logger = LoggerFactory.getLogger(SeatController.class);

    @Autowired
    protected HomeService homeService;

    /**
     * Simply selects the home view to render by returning its name.
     */
    @RequestMapping(value = "/seat", method = RequestMethod.GET)
    public String seat010(Locale locale, Model model)
    {
        logger.info("Welcome home! the client locale is "+ locale.toString());

        Date date = new Date();
        DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

        String formattedDate = dateFormat.format(date);

        model.addAttribute("serverTime", formattedDate );

        return "seat/seat010";
    }

    @RequestMapping(value="/{group}/{type}/list.do", method=RequestMethod.GET)
    public String list(@PathVariable String group, @PathVariable String type, Map modelMap, Command command) {

     command.setGroup(group);
     command.setType(type);

     homeService.list(modelMap, command);
     return group+"/"+type+"/list.tiles";
    }


}
